﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerAnimation : MonoBehaviour
{
    public PlayerController inputControl;
    public Animator anim;
    private Rigidbody2D rb;
    private PhysicsCheck physicCheck;
    private void Awake()
    {
        anim = GetComponent<Animator>();
        rb = GetComponent<Rigidbody2D>();
        physicCheck = GetComponent<PhysicsCheck>();
        inputControl = GetComponent<PlayerController>();
    }

    private void Update()
    {
        SetAnimation();
    }
    public void SetAnimation()
    {
        anim.SetFloat("velocityx",Mathf.Abs(rb.velocity.x));
        anim.SetFloat("velocityy", rb.velocity.y);
        anim.SetBool("isGround", physicCheck.isGround);
        anim.SetBool("isDead", inputControl.isDead);
        anim.SetBool("isAttack", inputControl.isAttack);
    }

    public void PlayerHurt()
    {
        anim.SetTrigger("hurt");
    }
    
    public void PlayerAttack()
    {
        anim.SetTrigger("attack");
    }
}
